﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B12_Delegate1
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string str = "hello world";
            //1、传递函数名
            ProcessString(str, SayEnglish);

            //2、传递匿名函数
            //函数只被调用一次时可以使用这种方法
            ProcessString(str, delegate (string name)
            {
                Console.WriteLine("Hello " + str);
            });

            Console.ReadKey();
        }

        public delegate void SayHi(string str);
        static void ProcessString(string name, SayHi hi)
        {
            hi(name);
        }

        static void SayChinese(string str)
        {
            Console.WriteLine("SayChinest:" + str);
        }

        static void SayEnglish(string str)
        {
            Console.WriteLine("SayEnglish:" + str);
        }

    }
}
